package com.ruoyi.jvm.lock;

public class Synchronize_Reentract {

    private final static Object object = new Object();

    public static void reentrantlock() {
        String tname = Thread.currentThread().getName();
        synchronized (object) {
            System.out.println(String.format("%s hold %s->monitor lock", tname, object));
            synchronized (object) {
                System.out.println(String.format("%s re-hold %s->monitor lock", tname, object));
            }
        }
    }

    /**
     * synchronized 是可重入锁
     */
    public static void main(String[] args) {
        Synchronize_Reentract.reentrantlock();
    }
}
